{% extends "hs-base.html" %}
{% block style %}
    <style type="text/css">
        .modal.fade.in {
            left: 25%;
        }
    </style>
{% endblock %}
{% block div %}

    <div class="content">

        <div class="container-fluid">

            <div class="row">
                <div class="col-12">
                    <div class="card-box">
                        <br>
                        <h4 class="header-title">服务器状态 </h4>

                        <div class="text-center mt-4 mb-4">
                            <div class="row">
                                <div class="col-xs-6 col-sm-3">
                                    {# 服务器总数 #}
                                    <div class="card-box widget-flat border-custom bg-custom text-white">
                                        <i class="fi-tag"></i>
                                        <h3 class="m-b-10">{{ server_num }}</h3>
                                        <p class="text-uppercase m-b-5 font-13 font-600">服务器总数</p>
                                    </div>
                                </div>
                                <div class="col-xs-6 col-sm-3">
                                    {# 个人总数 #}
                                    <div class="card-box bg-primary widget-flat border-primary text-white">
                                        <i class="fi-archive"></i>
                                        <h3 class="m-b-10">{{ pre_server_num }}</h3>
                                        <p class="text-uppercase m-b-5 font-13 font-600">个人总数</p>
                                    </div>
                                </div>
                                <div class="col-xs-6 col-sm-3">
                                    {# 已开启服务器总数 #}
                                    <div class="card-box widget-flat border-success bg-success text-white">
                                        <i class="fi-help"></i>
                                        <h3 class="m-b-10">{{ start_num }}</h3>
                                        <p class="text-uppercase m-b-5 font-13 font-600">已开启的服务器数量</p>
                                    </div>
                                </div>
                                <div class="col-xs-6 col-sm-3">
                                    {# 已关闭服务器总数 #}
                                    <div class="card-box bg-danger widget-flat border-danger text-white">
                                        <i class="fi-delete"></i>
                                        <h3 class="m-b-10">{{ stop_num }}</h3>
                                        <p class="text-uppercase m-b-5 font-13 font-600">已关闭的服务器数量</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <br>

                        <table class="table table-hover m-0 tickets-list table-actions-bar dt-responsive nowrap"
                               cellspacing="0" width="100%" id="datatable">
                            <thead>
                            <tr>
                                <th>环境名称</th>
                                <th>环境地址及接口</th>
                                <th>环境类别</th>
                                <th>创建日期</th>
                                <th>修改日期及修改人</th>
                                <th class="hidden-sm">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for server_list in server_lists %}
                                <tr>
                                    <td>{{ server_list[0][0] }}</td>
                                    <td>{{ server_list[0][2] }} : {{ server_list[0][3] }}</td>
                                    <td>{{ server_list[0][1] }}</td>
                                    <td>{{ server_list[0][6] }}</td>
                                    <td>{{ server_list[0][7] }}: {{ server_list[0][8] }}</td>
                                    <td>
                                        <div class="btn-group dropdown">
                                            <a href="javascript: void(0);"
                                               class="table-action-btn dropdown-toggle arrow-none btn btn-light btn-sm"
                                               data-toggle="dropdown" aria-expanded="false"><i
                                                    class="mdi mdi-dots-horizontal"></i></a>
                                            <div class="dropdown-menu dropdown-menu-right">
                                                {% if server_list[0][1] == '中间件' %}
                                                    <a class="dropdown-item btn" data-toggle="modal"
                                                       data-target="#updateForm" data-ip="{{ server_list[0][2] }}"
                                                       data-port="{{ server_list[0][3] }}"><i
                                                            class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>升级</a>
                                                {% elif server_list[0][1] == 'UFT' %}
                                                    <a class="dropdown-item btn" data-toggle="modal"
                                                       data-target="#updateForm" data-ip="UFT"
                                                       data-port="{{ server_list[0][3] }}"><i
                                                            class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>升级</a>
                                                {% else %}
                                                    <a class="dropdown-item btn" data-toggle="modal"
                                                       id="{{ server_list[0][2] }}" onclick="getpathname(this)"
                                                       data-ip="{{ server_list[0][2] }}" data-target="#bopForm"><i
                                                            class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>升级</a>
                                                    <input id="dar-ip" type="hidden" class="content1" name="host"
                                                           value="{{ server_list[0][2] }}">
                                                {% endif %}
                                                <a class="dropdown-item btn" data-toggle="modal" data-target="#pathForm"
                                                   data-ip="{{ server_list[0][2] }}"><i
                                                        class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>取包路径</a>
                                                <a class="dropdown-item btn" data-toggle="modal"
                                                   data-target="#updatepathForm" data-ip="{{ server_list[0][2] }}"><i
                                                        class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>升级路径</a>
                                                <a class="dropdown-item btn" data-toggle="modal"
                                                   data-target="#useshForm" data-ip="{{ server_list[0][2] }}"><i
                                                        class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>执行脚本</a>
                                                {% if server_list[0][1] == 'BOP' %}
                                                    <a class="dropdown-item btn"
                                                       href="http://10.20.27.20/bop-jar-version/{{ server_list[0][2] }}"><i
                                                            class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>查看JAR版本</a>
                                                {% endif %}
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            {% endfor %}

                            </tbody>

                        </table>
                        <br><br><br><br>
                    </div>

                </div><!-- end col -->
            </div>
            <!-- end row -->

        </div> <!-- container -->

    </div>
    <div id="updateForm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="card-box modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                </div>

                <div class="modal-body">
                    <p class="text-muted font-14 m-b-20">请在下方填写升级相关信息</p>


                    <div class="form-group">
                        <label>升级方式</label>
                        <div>
                            <select class="form-control select2" name="update_way" onchange="show_or_hide(this.value)">
                                <option value="1"> 修改单号升级</option>
                                <option value="2"> 上传文件升级</option>
                            </select>
                        </div>
                    </div>

                    <form action="#" class="sheet-form-1" method="post">


                        <div class="form-group">
                            <label>输出程序</label><br>
                            <div>
                                <input type="text" id="output" name="output" class="form-control" required
                                       data-parsley-minlength="6" placeholder="例：/规范化递交/M201801010101-XXXXX/"/>
                                <input type="hidden" class="content" name="host" value=#data-ip>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>版本</label>
                            <div>
                                <input type="text" id="version" name="version" class="form-control" required
                                       data-parsley-maxlength="6" placeholder="例：V1"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>所属产品</label>
                            <div>
                                <select class="form-control select2" name="en_product">
                                    <option value="测试平台1"> 测试平台1</option>
                                    <option value="测试平台2"> 测试平台2</option>
                                    <option value="测试平台3"> 测试平台3</option>
                                </select>
                            </div>
                        </div>

                        <button type="submit" class="btn btn-custom waves-effect waves-light" name="fun" value="update">
                            升级
                        </button>
                        <button type="reset" data-dismiss="modal" class="btn btn-default btn-light waves-effect m-l-5">
                            关闭
                        </button>
                    </form>
                    <form action="#" method="post" class="dropzone sheet-form-2" enctype="multipart/form-data">

                        <div class="fallback form-group">
                            <input name="file" type="file" multiple>
                        </div>
                        <input type="hidden" name="dirname" value="{{ value_random }}">
                    </form>
                    <br>
                    <form action="#" method="post" class="sheet-form-2">
                        <input type="hidden" name="random_path" value="{{ value_random }}">
                        <input type="hidden" class="content" name="host" value=#data-ip>
                        <button type="submit" class="btn btn-custom waves-effect waves-light" name="fun" value="upload">
                            升级
                        </button>
                        <button type="reset" data-dismiss="modal" class="btn btn-default btn-light waves-effect m-l-5">
                            关闭
                        </button>
                    </form>
                </div>


            </div>
        </div>
    </div>
    <div id="pathForm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="card-box modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="Formtitle">取包环境路径</h4>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                </div>

                <div class="modal-body">
                    <p class="text-muted font-14 m-b-20">请在下方填写路径相关信息</p>

                    <form action="#" method="post">
                        <div class="form-group">
                            <label>路径名称</label><br>
                            <div>
                                <input type="text" id="path_name" name="path_name" class="form-control" required
                                       data-parsley-minlength="6" placeholder="例：55trade取包路径"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>取包地址</label><br>
                            <div>
                                <input type="text" id="path_ip" name="path_ip" class="form-control" required
                                       data-parsley-minlength="6" placeholder="例：120.0.0.1"/>
                                <input type="hidden" class="content" name="host" value=#data-ip>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>取包端口</label>
                            <div>
                                <input type="text" id="path_port" name="path_port" class="form-control" required
                                       data-parsley-maxlength="6" placeholder="例：5212"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>取包用户名</label>
                            <div>
                                <input type="text" id="path_user" name="path_user" class="form-control" required
                                       data-parsley-maxlength="6" placeholder="例：root"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>取包密码</label>
                            <div>
                                <input type="text" id="path_password" name="path_password" class="form-control" required
                                       data-parsley-maxlength="6" placeholder="例：*******"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>取包路径</label>
                            <div>
                                <input type="text" name="get_path" class="form-control" required
                                       data-parsley-length="[5,10]"
                                       placeholder="请填写压缩包下载ftp路径"/>
                            </div>
                        </div>
                        <br>
                        <button type="submit" class="btn btn-custom waves-effect waves-light" name="fun" value="path">
                            确定
                        </button>
                        <button type="button" data-dismiss="modal" class="btn btn-default btn-light waves-effect m-l-5">
                            关闭
                        </button>
                    </form>
                </div>


            </div>
        </div>
    </div>
    <div id="updatepathForm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="card-box modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="Formtitle">升级环境路径</h4>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                </div>

                <div class="modal-body">
                    <p class="text-muted font-14 m-b-20">请在下方填写路径相关信息</p>

                    <form action="#" method="post">
                        <div class="form-group">
                            <label>路径名称</label><br>
                            <div>
                                <input type="text" id="path_name" name="path_name" class="form-control" required
                                       data-parsley-minlength="6" placeholder="例：55升级路径"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>升级地址</label><br>
                            <div>
                                <input type="text" id="path_ip" name="path_ip" class="form-control" required
                                       data-parsley-minlength="6" placeholder="例：120.0.0.1"/>
                                <input type="hidden" class="content" name="host" value=#data-ip>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>升级端口</label>
                            <div>
                                <input type="text" id="path_port" name="path_port" class="form-control" required
                                       data-parsley-maxlength="6" placeholder="例：22"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>升级路径用户名</label>
                            <div>
                                <input type="text" id="path_user" name="path_user" class="form-control" required
                                       data-parsley-maxlength="6" placeholder="例：root"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>升级路径密码</label>
                            <div>
                                <input type="text" id="path_password" name="path_password" class="form-control" required
                                       data-parsley-maxlength="6" placeholder="例：*******"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>升级路径</label>
                            <div>
                                <input id = "to_path" type="text" name="to_path" class="form-control" required
                                       data-parsley-length="[5,10]"
                                       placeholder="请填写升级包放置路径,例:/home/tomcat/apach-tomcat/webapps/"/>
                            </div>
                        </div>
                        <br>
                        <button type="submit" class="btn btn-custom waves-effect waves-light" name="fun"
                                value="updatepath">
                            确定
                        </button>
                        <button type="button" data-dismiss="modal" class="btn btn-default btn-light waves-effect m-l-5">
                            关闭
                        </button>
                    </form>
                </div>


            </div>
        </div>
    </div>
    <div id="bopForm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="card-box modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                </div>

                <div class="modal-body">
                    <p class="text-muted font-14 m-b-20">请在下方填写升级相关信息</p>
                    <form action="#" method="post">
                        <div class="form-group">
                            <div>
                                <label>选择取包路径</label>

                                <select id="select_name" class="form-control select2" name="update_name">
                                </select>
                                <br>

                            </div>
                        </div>

                        <div class="form-group">
                            <div>
                                <label>选择版本</label>

                                <select id="select_bop" class="form-control select2" name="update_path">
                                </select>
                                <br>

                                <input id="bop-ip" type="hidden" class="content1" name="host" value=#data-ip>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>选择升级文件</label>
                            <select id="select_bop2" name="update_war"
                                    class="select2 form-control select2-multiple select2-hidden-accessible" multiple
                                    data-placeholder="请选择">
                            </select>
                        </div>
                        <div class="form-group">
                            <div>
                                <label>选择升级路径</label>

                                <select id="select_upname" class="form-control select2"  name="toupdate_name" data-placeholder="请选择">
                                </select>
                                <br>

                            </div>
                        </div>


                        <button type="submit" class="btn btn-custom waves-effect waves-light" name="fun"
                                value="bopupdate">
                            升级
                        </button>
                        <button type="reset" data-dismiss="modal" class="btn btn-default btn-light waves-effect m-l-5">
                            关闭
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div id="useshForm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="card-box modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                </div>

                <div class="modal-body">
                    <p class="text-muted font-14 m-b-20">请在下方填写脚本相关信息</p>
                    <form action="#" method="post">


                        <div class="form-group">
                            <label>脚本路径</label><br>
                            <div>
                                <input type="text" id="sh_path" name="sh_path" class="form-control" required
                                       data-parsley-minlength="6" placeholder="例：/home/hundsun/xx">
                                <input type="hidden" class="content" name="host" value=#data-ip>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>脚本名称</label>
                            <div>
                                <input type="text" id="sh_name" name="sh_name" class="form-control" required
                                       data-parsley-maxlength="6" placeholder="例：test.sh">
                            </div>
                        </div>
                        <button type="submit" class="btn btn-custom waves-effect waves-light" name="fun" value="use_sh">
                            执行
                        </button>
                        <button type="reset" data-dismiss="modal" class="btn btn-default btn-light waves-effect m-l-5">
                            关闭
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block script %}
    <script type="text/javascript">

        $(".fa-chevron-right").on('click', function (event) {
            var flag = $(this).attr("data-flag");
            $(".click" + flag).toggle();
            var $this = $(this);
            if ($this.hasClass('fa-chevron-right')) {
                $this.removeClass('fa-chevron-right').addClass('fa-chevron-down');
            } else {
                $this.removeClass('fa-chevron-down').addClass('fa-chevron-right');
            }
        });


        function closedar() {
            $('#updateForm').modal('hide');//隐藏modal
            $('#UFTupdateForm').modal('hide');
            $('.modal-backdrop').remove();//去掉遮罩层

        }

        $('body').on('hidden.bs.modal', '.modal', function () {
            $(this).removeData("bs.modal");
        });

        function openSever(obj) {
            var getId = {id_num: obj.id, fun: 'openSever'}
            if (confirm("确定开启吗？")) {
                $.ajax({
                    type: 'POST',
                    data: getId,
                    success: function () {
                    },
                    error: function (e) {
                        alert("开启失败")

                    }

                })
            }

        }

        function closeSever(obj) {
            var getId = {id_num: obj.id, fun: 'closeSever'}
            if (confirm("确定关闭吗？")) {
                $.ajax({
                    type: 'POST',
                    data: getId,
                    success: function () {
                    },
                    error: function (e) {
                        alert("关闭失败")

                    }

                })
            }

        }

        function getpathname(obj) {
            var data = {bopip: obj.id, fun: 'getpathname'};
            $.ajax({
                type: 'POST',
                url: "/middle-server",
                data: data,  //转化字符串
                success: function (data) { //成功的话，得到消息
                    //alert(data);
                    addselect2(data['path']);
                    addselect3(data['topath']);
                }
            });

        }
        $(document).ready(function () {
            $("#select_name").on('change', function () {
                var objS = document.getElementById('select_name');
                var ip = document.getElementById('bop-ip').value;
                var bname = document.getElementById('select_name').value;
                var provice = objS.options[objS.selectedIndex].value;
                var data = {};
                data['fun'] = 'getbop';
                data['bopip'] = ip;
                data['bopname'] = bname;
                $.ajax({
                    type: 'POST',
                    url: "/middle-server",
                    data: data,
                    success: function (data) {
                        //alert(data);
                        addselect(data);
                    }
                });
            });
        });


        $(document).ready(function () {
            $("#select_bop").on('change', function () {
                var objS = document.getElementById('select_bop');
                var ip = document.getElementById('bop-ip').value;
                var bname = document.getElementById('select_name').value;
                var provice = objS.options[objS.selectedIndex].value;
                var data = {};
                data['fun'] = 'getbop_version';
                data['version'] = provice;
                data['bopip'] = ip;
                data['bopname'] = bname;
                $.ajax({
                    type: 'POST',
                    url: "/middle-server",
                    data: data,
                    success: function (data) {
                        //alert(data);
                        addselect1(data);
                    }
                });
            });
        });
         /*$(document).ready(function () {
            $("#select_upname").on('change', function () {
                var ip = document.getElementById('bop-ip').value;
                var path_name = document.getElementById('select_upname').value;
                var data = {};
                data['fun'] = 'gettomcat_unique';
                data['bopip'] = ip;
                data['pathname'] = path_name;
                $.ajax({
                    type: 'POST',
                    url: "/middle-server",
                    data: data,
                    success: function (data) {
                        //alert(data);
                        addselect_tomcat_unique(data);
                    }
                });
            });
        });*/

        //下拉框全选方法
        function check_all(select_id) {
              //获取特定id的所有元素
              var item = document.getElementById(select_id);
              //获取jquery对象
              var options = item.options;
              var item_jq = $('#'+select_id);
              var option_list = [];
              for(var i=0; i< options.length;i++){
                 var optionVal = options[i].value;
                 //不能将全选加入栏中，否则会触发死循环
                  if (optionVal == '全选') {
                      continue;
                  }
                 option_list.push(optionVal);
              }
              item_jq.val(option_list).trigger("change");
        }

        function addselect(data) {
            number = data.split(" ");
            var select = document.getElementById("select_bop");
            //删除所有原来的子结点元素
            $("#select_bop").empty();
            for (var i = 0; i < number.length; ++i) {
                var newItem = document.createElement("option");
                var newItemText = document.createTextNode(number[i]);
                newItem.appendChild(newItemText);
                select.appendChild(newItem);
            }
        }

        function addselect2(data) {
            number = data.split(" ");
            var select = document.getElementById("select_name");
            //删除所有原来的子结点元素
            $("#select_name").empty();
            for (var i = 0; i < number.length; ++i) {
                var newItem = document.createElement("option");
                var newItemText = document.createTextNode(number[i]);
                newItem.appendChild(newItemText);
                select.appendChild(newItem);
            }
        }

        function addselect3(data) {
            number = data.split(" ");
            var select = document.getElementById("select_upname");
            //删除所有原来的子结点元素
            $("#select_upname").empty();
            if (number.length==0){
                var newItem = document.createElement("option");
                var newItemText = document.createTextNode("请选择");
                newItem.appendChild(newItemText);
                select.appendChild(newItem);
            }else {
                for (var i = 0; i < number.length; ++i) {
                    if(i==0){
                        var newItem = document.createElement("option");
                        var newItemText = document.createTextNode("请选择");
                        newItem.appendChild(newItemText);
                        select.appendChild(newItem);
                    }
                    var newItem = document.createElement("option");
                    var newItemText = document.createTextNode(number[i]);
                    newItem.appendChild(newItemText);
                    select.appendChild(newItem);
                }
            }


        }


        function addselect1(data) {
            number = data.split(" ");
            var select = document.getElementById("select_bop2");
            //删除所有原来的子结点元素
            $("#select_bop2").empty();
            for (var i = 0; i < number.length; ++i) {
                // 暂时前端不展示bop-flow-view.war和
                if(number[i]=="bop-flow-view.war"||number[i]=="aiaudit.war"){
                    continue;
                }
                if (i == 0) {
                    var newItem = document.createElement("option");
                    var newItemText = document.createTextNode("全选");
                    newItem.appendChild(newItemText);
                    select.appendChild(newItem);
                }
                var newItem = document.createElement("option");
                newItem.className = 'bop-war'
                var newItemText = document.createTextNode(number[i]);
                newItem.appendChild(newItemText);
                select.appendChild(newItem);
            }$("#select_bop2").change(function() {
                // 获取已经选中的选项
                var selected_list = $("#select_bop2 option:selected").text();//获取text值
                if (selected_list.includes("全选")) {
                        check_all("select_bop2");
                }
            });
        }
    /*
        function addselect_tomcat_unique(data) {
            number = data.split(" ");
            var select = document.getElementById("select_tomcat_unique");
            //删除所有原来的子结点元素
            $("#select_tomcat_unique").empty();
            for (var i = 0; i < number.length; ++i) {
                if (number.length == 0) {
                    var newItem = document.createElement("option");
                    var newItemText = document.createTextNode("请选择");
                    newItem.appendChild(newItemText);
                    select.appendChild(newItem);
                }else {
                    if(i==0){
                        var newItem = document.createElement("option");
                        var newItemText = document.createTextNode("请选择");
                        newItem.appendChild(newItemText);
                        select.appendChild(newItem);
                    }
                    var newItem = document.createElement("option");
                    var newItemText = document.createTextNode(number[i]);
                    newItem.appendChild(newItemText);
                    select.appendChild(newItem);
                }
            }
        }*/
        function check_str(reg,str) {
            if (reg.test(str)) {
                return true
            } else {
                return false
            }
        }




        function show_or_hide(v) {
            if (v == "1") {
                $(".sheet-form-2").hide();
                $(".sheet-form-1").show();
            } else if (v == "2") {
                $(".sheet-form-2").show();
                $(".sheet-form-1").hide();
            }
        }

        $(document).ready(function () {
            $(".sheet-form-2").hide();
        });
        $('#updateForm').on('show.bs.modal', function (event) {
            var btn = $(event.relatedTarget);
            var modal = $(this);
            var modalValue = btn.data('ip');
            modal.find('.content').val(modalValue);
        })
        $('#bopForm').on('show.bs.modal', function (event) {
            var btn = $(event.relatedTarget);
            var modal = $(this);
            var modalValue = btn.data('ip');
            modal.find('.content1').val(modalValue);

        })

        $('#useshForm').on('show.bs.modal', function (event) {
            var btn = $(event.relatedTarget);
            var modal = $(this);
            var modalValue = btn.data('ip');
            modal.find('.content').val(modalValue);


        })


        $('#pathForm').on('show.bs.modal', function (event) {
            var btn = $(event.relatedTarget);
            var modal = $(this);
            var modalValue = btn.data('ip');
            modal.find('.content').val(modalValue);
        })
        $('#updatepathForm').on('show.bs.modal', function (event) {
            var btn = $(event.relatedTarget);
            var modal = $(this);
            var modalValue = btn.data('ip');
            modal.find('.content').val(modalValue);
        })
        $('input[name="to_path"]').on('change', function(){
                var reg = /(.*)\/webapps\//
                var topath = $(this).val()
                if (!check_str(reg,topath)) {
                    alert("请输入合法的升级路径\n")
                    $("#to_path").val("");
                }
        });

    </script>

{% endblock %}